﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Chrome="clr-namespace:XamlingCore.SL.Controls.Chrome" xmlns:Navigation="clr-namespace:XamlingCore.SL.Controls.Navigation" xmlns:controls="clr-namespace:XamlingCore.SL.Controls.Content">

    <Style TargetType="Navigation:XNavigationFrame">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Navigation:XNavigationFrame">
                    <controls:XTransitionContentControl x:Name="TransControl"
                        ReverseTransition="{Binding NavigationService.IsReverseNavigation}"  
                        Content="{Binding NavigationService.CurrentContentObject}" 
                        TransitionsEnabled="{Binding TransitionsEnabled}"
                        VerticalAlignment="Stretch" 
                        HorizontalAlignment="Stretch"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Chrome:ApplicationWindow">
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="TabNavigation" Value="Cycle"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="#FFEEEEEE"/>
        <Setter Property="Foreground" Value="#FFFFFFFF"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Chrome:ApplicationWindow">
                    <Grid x:Name="Root">
                        <Grid.Resources>
                            <Style x:Key="ButtonStyle" TargetType="Button">
                                <Setter Property="Background" Value="#FF1F3B53"/>
                                <Setter Property="Foreground" Value="#FF000000"/>
                                <Setter Property="Padding" Value="3"/>
                                <Setter Property="BorderThickness" Value="1"/>
                                <Setter Property="BorderBrush">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFA3AEB9" Offset="0"/>
                                            <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                            <GradientStop Color="#FF718597" Offset="0.375"/>
                                            <GradientStop Color="#FF617584" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid x:Name="grid" Background="#02FFFFFF" HorizontalAlignment="Center" Height="14" VerticalAlignment="Center" Width="15">
                                                <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Center" Content="{TemplateBinding Content}" />
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>
                        <Grid x:Name="ContentRoot" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Height="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" VerticalAlignment="{TemplateBinding VerticalAlignment}" Width="{TemplateBinding Width}">
                            <Border Margin="0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="0">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Border x:Name="Chrome" BorderThickness="0" Width="Auto" Background="{TemplateBinding BorderBrush}">
                                        <Grid Height="Auto" Width="Auto" Margin="0,0,4,0">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition/>
                                                <ColumnDefinition Width="14"/>
                                                <ColumnDefinition Width="14"/>
                                                <ColumnDefinition Width="14"/>
                                            </Grid.ColumnDefinitions>
                                            <ContentControl Content="{TemplateBinding Title}" Foreground="{TemplateBinding Foreground}" 
                                                            FontFamily="{TemplateBinding FontFamily}" FontStretch="{TemplateBinding FontStretch}" 
                                                            FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}" 
                                                            HorizontalAlignment="Stretch" IsTabStop="False" Margin="6,0,0,0" VerticalAlignment="Center"/>
                                            <Button x:Name="MinimizeButton" Grid.Column="1" HorizontalAlignment="Center" Height="14" IsTabStop="False" Style="{StaticResource ButtonStyle}" VerticalAlignment="Center" Width="14">
                                                <Path Data="M1,1 L9,1 L9,9 L1,9 z M1.1250012,7 L9.000001,7" Fill="Transparent" HorizontalAlignment="Center" Height="10" Stretch="Fill" 
                                                      Stroke="#FFFFFFFF" StrokeThickness="2" UseLayoutRounding="True" VerticalAlignment="Center" Width="10" />
                                            </Button>
                                            <Button x:Name="MaximizeButton" Grid.Column="2" HorizontalAlignment="Center" Height="14" IsTabStop="False" Style="{StaticResource ButtonStyle}" VerticalAlignment="Center" Width="14">
                                                <Path Data="M1,1 L9,1 L9,9 L1,9 z M1.1219903,3 L8.8749905,3" Fill="Transparent" HorizontalAlignment="Center" Height="10" Stretch="Fill" 
                                                      Stroke="#FFFFFFFF" StrokeThickness="2" UseLayoutRounding="True" VerticalAlignment="Center" Width="10"/>
                                            </Button>
                                            <Button x:Name="CloseButton" Grid.Column="3" HorizontalAlignment="Center" Height="14" IsTabStop="False" Style="{StaticResource ButtonStyle}" VerticalAlignment="Center" Width="14">
                                                <Path Data="M1,9.000001 L9,1.0000017 M1,1 L9,9" Fill="Transparent" HorizontalAlignment="Center" Height="10" 
                                                      Stretch="Fill" Stroke="#FFFFFFFF" UseLayoutRounding="True" VerticalAlignment="Center" Width="10" 
                                                      StrokeThickness="2" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
                                            </Button>
                                        </Grid>
                                    </Border>
                                    <Border Background="{TemplateBinding Background}" Margin="0" Grid.Row="1">
                                        <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                    </Border>
                                    <Path x:Name="ResizeHandle" Data="M12.5,0.5 L12.5,12.5 L0.5,12.5 z M3.1609595,12.520396 L12.56307,2.9729376 M5.6818972,12.520925 L12.51118,5.8148241 M8.4299183,12.561848 L12.498879,8.6963005" 
                                          Height="13.062" Stretch="Fill" Grid.Row="1" Margin="0,0,-1,-1"
                                          Stroke="{TemplateBinding BorderBrush}" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="13.063" UseLayoutRounding="False" Fill="Transparent" />
                                </Grid>
                            </Border>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultXTransitionStyle" TargetType="controls:XTransitionContentControl">

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:XTransitionContentControl">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ContentStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.5">
                                        <VisualTransition.GeneratedEasingFunction>
                                            <CubicEase EasingMode="EaseOut"/>
                                        </VisualTransition.GeneratedEasingFunction>
                                    </VisualTransition>
                                    <VisualTransition GeneratedDuration="0" To="BeforeTransition"/>
                                    <VisualTransition GeneratedDuration="0" To="BeforeTransitionReverse"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="NoContent">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="oldContentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="oldContentPresenter" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="contentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="oldContentPresenter" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="oldContentPresenter" />
                                        <DoubleAnimation Duration="0" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="oldContentPresenter" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="oldContentPresenter" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="oldContentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="contentPresenter" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="BeforeTransition">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="contentPresenter" />
                                        <DoubleAnimation Duration="0" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="contentPresenter" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="contentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="oldContentPresenter" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="NormalReverse">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="oldContentPresenter" />
                                        <DoubleAnimation Duration="0" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="oldContentPresenter" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="oldContentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="oldContentPresenter" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="contentPresenter" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="BeforeTransitionReverse">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="oldContentPresenter" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="contentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)" Storyboard.TargetName="contentPresenter" />
                                        <DoubleAnimation Duration="0" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="contentPresenter" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="VisualStateGroup"/>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter x:Name="oldContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" RenderTransformOrigin="0.5,0.5">
                            <ContentPresenter.RenderTransform>
                                <CompositeTransform/>
                            </ContentPresenter.RenderTransform>
                            <ContentPresenter.Projection>
                                <PlaneProjection CenterOfRotationX="0"/>
                            </ContentPresenter.Projection>
                        </ContentPresenter>
                        <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" RenderTransformOrigin="0.5,0.5">
                            <ContentPresenter.RenderTransform>
                                <CompositeTransform/>
                            </ContentPresenter.RenderTransform>
                            <ContentPresenter.Projection>
                                <PlaneProjection CenterOfRotationX="1"/>
                            </ContentPresenter.Projection>
                        </ContentPresenter>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
